package com.aidysoft.practice.easypoi.demo1.controller;

import com.aidysoft.practice.easypoi.utils.ExcelUtil;
import com.aidysoft.practice.easypoi.utils.WordUtil;
import com.aidysoft.practice.easypoi.utils.pojo.wordExportImage.WordImageEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
@Controller
public class WordController {
    /**
     * 导出 wordExportImage
     *
     * @param request
     * @param response
     * @return
     */
    @GetMapping("/exportWord")
    public String exportWord(HttpServletRequest request, HttpServletResponse response) {
        Map<String, Object> params = new HashMap<>();
        params.put("title", "这是标题");
        params.put("name", "李四");
        WordImageEntity image = new WordImageEntity();
        image.setHeight(200);
        image.setWidth(500);
        image.setUrl("pic/aaa.png");
        image.setType(WordImageEntity.URL);
        params.put("pic", image);
        WordUtil.exportWord("templates/export1.docx", "abcd.docx", params, request, response);
        return "ok2";
    }

}
